home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume9 / xinvaders / patch3 next >
Encoding:
Internet Message Format  |  1990-08-31  |  13.6 KB

  1. Path: uunet!jarthur!usc!snorkelwacker!apple!sun-barr!newstop!sun!parc.xerox.com
  2. From: jgoldman@parc.xerox.com (Jonny Goldman)
  3. Newsgroups: comp.sources.x
  4. Subject: v09i014: xinvaders, Patch3, Part01/01
  5. Message-ID: <141677@sun.Eng.Sun.COM>
  6. Date: 31 Aug 90 16:42:24 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 485
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: Jonny Goldman <jgoldman@parc.xerox.com>
  12. Posting-number: Volume 9, Issue 14
  13. Archive-name: xinvaders/patch3
  14. Patch-To: xinvaders: Volume 8, Issues 62-66,68,70
  15.  
  16. This is patch file #3 to the xinvaders game.  I've incorporated code to
  17. search the applications-defaults directory for resources, and added bitmaps
  18. for explosions when you hit the aliens (like the original game).
  19.  
  20. The patch expects you to have the previous patch in place.
  21.  
  22. There are two new bitmap (.bit) files, vexlod1.bit and vexlod2.bit
  23.  
  24. The files that changed are:
  25.  
  26. diff -c xinvaders.2/Imakefile xinvaders/Imakefile
  27. diff -c xinvaders.2/main.c xinvaders/main.c
  28. diff -c xinvaders.2/patchlevel.h xinvaders/patchlevel.h
  29. diff -c xinvaders.2/shot.c xinvaders/shot.c
  30. diff -c xinvaders.2/spacers.c xinvaders/spacers.c
  31. diff -c xinvaders.2/vaders.c xinvaders/vaders.c
  32. diff -c xinvaders.2/vaders.h xinvaders/vaders.h
  33.  
  34. I've put the context diff and the bitmaps in a sharfile.  It expects the
  35. old source to be in the directory xinvaders.2, and the new source to be in
  36. the directory xinvaders (which at the start has a complete copy of
  37. xinvaders.2).
  38.  
  39. -------------------------Cut Here ----------------------------
  40. #! /bin/sh
  41. # This is a shell archive.  Remove anything before this line, then unpack
  42. # it by saving it into a file and typing "sh file".  To overwrite existing
  43. # files, type "sh file -c".  You can also feed this as standard input via
  44. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  45. # will see the following message at the end:
  46. #        "End of shell archive."
  47. # Contents:  xinvaders.3.diffs xinvaders/vexplod1.bit
  48. #   xinvaders/vexplod2.bit
  49. # Wrapped by jgoldman@philo on Thu Aug 30 10:31:06 1990
  50. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  51. if test -f 'xinvaders.3.diffs' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'xinvaders.3.diffs'\"
  53. else
  54. echo shar: Extracting \"'xinvaders.3.diffs'\" \(9325 characters\)
  55. sed "s/^X//" >'xinvaders.3.diffs' <<'END_OF_FILE'
  56. Xdiff -c xinvaders.2/Imakefile xinvaders/Imakefile
  57. X*** xinvaders.2/Imakefile    Wed Aug  1 13:40:41 1990
  58. X--- xinvaders/Imakefile    Thu Aug 30 09:35:58 1990
  59. X***************
  60. X*** 1,4 ****
  61. X! LOCAL_LIBRARIES = $(XAWLIB) $(XTOOLLIB) $(XMULIB) $(XLIB)
  62. X  
  63. X  OBJS = spacers.o base.o widget.o main.o vaders.o shot.o score.o
  64. X  
  65. X--- 1,4 ----
  66. X! LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
  67. X  
  68. X  OBJS = spacers.o base.o widget.o main.o vaders.o shot.o score.o
  69. X  
  70. XOnly in xinvaders.2: bits
  71. Xdiff -c xinvaders.2/main.c xinvaders/main.c
  72. X*** xinvaders.2/main.c    Thu Aug 30 10:17:21 1990
  73. X--- xinvaders/main.c    Thu Aug 30 09:36:39 1990
  74. X***************
  75. X*** 24,33 ****
  76. X  #include <X11/VPaned.h>
  77. X  #endif
  78. X  static int width, height;        /* Size of window. */
  79. X- static Pixel defaultfore;    /* Default foreground */
  80. X- Pixel defaultback;    /* Default background */
  81. X- static Pixel scorepixel;    /* Color for score. */
  82. X  
  83. X  static XrmOptionDescRec table[] = {
  84. X      {"-debug",    "*debug",    XrmoptionNoArg,    NULL},
  85. X  };
  86. X--- 24,34 ----
  87. X  #include <X11/VPaned.h>
  88. X  #endif
  89. X  static int width, height;        /* Size of window. */
  90. X  
  91. X+ #ifdef XFILESEARCHPATH
  92. X+ static void AddPathToSearchPath();
  93. X+ #endif
  94. X+ 
  95. X  static XrmOptionDescRec table[] = {
  96. X      {"-debug",    "*debug",    XrmoptionNoArg,    NULL},
  97. X  };
  98. X***************
  99. X*** 124,129 ****
  100. X--- 125,133 ----
  101. X      Widget pane;
  102. X      extern WidgetClass labelwidgetclass;
  103. X      srandom(time(0));
  104. X+ #ifdef XFILESEARCHPATH
  105. X+     AddPathToSearchPath(XFILESEARCHPATH);
  106. X+ #endif
  107. X      toplevel = XtInitialize(argv[0], "Vaders", table, XtNumber(table),
  108. X                  &argc, argv);
  109. X      dpy = XtDisplay(toplevel);
  110. X***************
  111. X*** 171,173 ****
  112. X--- 175,223 ----
  113. X      fprintf(stderr, "%s\n", msg);
  114. X      exit(1);
  115. X  }
  116. X+ 
  117. X+ 
  118. X+ #ifdef XFILESEARCHPATH
  119. X+ static void
  120. X+ AddPathToSearchPath(path)
  121. X+ char *path;
  122. X+ {
  123. X+      char *old, *new;
  124. X+      extern char *getenv();
  125. X+      
  126. X+      old = getenv("XFILESEARCHPATH");
  127. X+      if (old) {
  128. X+ #if defined(mips) || defined(hpux) || defined(sun)
  129. X+       /* +1 for =, +2 for :, +3 for null */
  130. X+       new = XtMalloc((Cardinal) (strlen("XFILESEARCHPATH") +
  131. X+                      strlen(old) +
  132. X+                      strlen(path) + 3));
  133. X+       (void) strcpy(new, "XFILESEARCHPATH");
  134. X+       (void) strcat(new, "=");
  135. X+       (void) strcat(new, old);
  136. X+       (void) strcat(new, ":");
  137. X+       (void) strcat(new, path);
  138. X+       putenv(new);
  139. X+ #else
  140. X+       /* +1 for colon, +2 for null */
  141. X+       new = XtMalloc((Cardinal) (strlen(old) + strlen(path) + 2));
  142. X+       (void) strcpy(new, old);
  143. X+       (void) strcat(new, ":");
  144. X+       (void) strcat(new, path);
  145. X+       setenv("XFILESEARCHPATH", new, 1);
  146. X+ #endif
  147. X+      }
  148. X+      else {
  149. X+ #if defined(mips) || defined(hpux) || defined(sun)
  150. X+       new = XtMalloc((Cardinal) (strlen("XFILESEARCHPATH") +
  151. X+                      strlen(path) + 2));
  152. X+       (void) strcpy(new, "XFILESEARCHPATH");
  153. X+       (void) strcat(new, "=");
  154. X+       (void) strcat(new, path);
  155. X+       putenv(new);
  156. X+ #else
  157. X+       setenv("XFILESEARCHPATH", path, 1);
  158. X+ #endif
  159. X+      }
  160. X+ }
  161. X+ #endif
  162. Xdiff -c xinvaders.2/patchlevel.h xinvaders/patchlevel.h
  163. X*** xinvaders.2/patchlevel.h    Tue Aug  7 17:13:10 1990
  164. X--- xinvaders/patchlevel.h    Thu Aug 30 10:07:58 1990
  165. X***************
  166. X*** 8,19 ****
  167. X  
  168. X  Jonny Goldman <jgoldman@parc.xerox.com>
  169. X  
  170. X! Tue Jul 17 1990
  171. X  */
  172. X  
  173. X  /* patchlevel.h -- patchlevel for xinvaders */
  174. X  
  175. X! #define PATCHLEVEL 2
  176. X  
  177. X  /* 
  178. X    version 1.1:
  179. X--- 8,19 ----
  180. X  
  181. X  Jonny Goldman <jgoldman@parc.xerox.com>
  182. X  
  183. X! Thu Aug 30 1990
  184. X  */
  185. X  
  186. X  /* patchlevel.h -- patchlevel for xinvaders */
  187. X  
  188. X! #define PATCHLEVEL 3
  189. X  
  190. X  /* 
  191. X    version 1.1:
  192. X***************
  193. X*** 25,29 ****
  194. X--- 25,35 ----
  195. X    version 1.2:
  196. X    added multi-resolution code.  created new bitmaps for large-scale.
  197. X    added new resource for scale: Vaders*Scale, 1=normal, 2=large.
  198. X+ 
  199. X+   version 1.3:
  200. X+   added explosions for aliens.
  201. X+   cleaned up some dirty code so the program will compile without 
  202. X+    complaints from gcc and added applications-default directory search
  203. X+    - from jik@athena.mit.edu
  204. X  
  205. X  */
  206. Xdiff -c xinvaders.2/shot.c xinvaders/shot.c
  207. X*** xinvaders.2/shot.c    Tue Aug  7 15:32:08 1990
  208. X--- xinvaders/shot.c    Thu Aug 30 09:36:50 1990
  209. X***************
  210. X*** 83,89 ****
  211. X  Opaque closure;
  212. X  XtIntervalId id;
  213. X  {
  214. X!   int i, x, y, newx, newy;
  215. X    Shot shot;
  216. X    if (closure != (Opaque) MoveShots) return;
  217. X    if (!paused) {
  218. X--- 83,89 ----
  219. X  Opaque closure;
  220. X  XtIntervalId id;
  221. X  {
  222. X!   int i, x, y, newy;
  223. X    Shot shot;
  224. X    if (closure != (Opaque) MoveShots) return;
  225. X    if (!paused) {
  226. X***************
  227. X*** 135,141 ****
  228. X  Opaque closure;
  229. X  XtIntervalId id;
  230. X  {
  231. X!   int i, x, y, newx, newy;
  232. X    Shot vshot;
  233. X  
  234. X    if (closure != (Opaque) MoveVshots) return;
  235. X--- 135,141 ----
  236. X  Opaque closure;
  237. X  XtIntervalId id;
  238. X  {
  239. X!   int i, x, y, newy;
  240. X    Shot vshot;
  241. X  
  242. X    if (closure != (Opaque) MoveVshots) return;
  243. Xdiff -c xinvaders.2/spacers.c xinvaders/spacers.c
  244. X*** xinvaders.2/spacers.c    Tue Aug  7 15:29:02 1990
  245. X--- xinvaders/spacers.c    Thu Aug 30 09:37:00 1990
  246. X***************
  247. X*** 65,72 ****
  248. X  
  249. X  static void DestroySpacer()
  250. X  {
  251. X-   XImage ximage;
  252. X-   int num, value, ex, ey;
  253. X    score += spacer->score;
  254. X    PaintScore();
  255. X  
  256. X--- 65,70 ----
  257. X***************
  258. X*** 108,115 ****
  259. X       Opaque closure;
  260. X       XtIntervalId id;
  261. X  {
  262. X-   register int i;
  263. X-   int minx, miny, maxx, maxy, spy;
  264. X    if (closure != (Opaque) MoveSpacer) return;
  265. X    spacertimerid = XtAddTimeOut(spacerwait, MoveSpacer, (Opaque) MoveSpacer);
  266. X    if (!paused) {
  267. X--- 106,111 ----
  268. X***************
  269. X*** 139,145 ****
  270. X  {
  271. X    unsigned int width, height;
  272. X    int x_hot, y_hot;
  273. X!   unsigned char *data, filename[255];
  274. X    int status;
  275. X  
  276. X    sprintf(filename, "%sspacer%d.bit", bitdir, scale);
  277. X--- 135,141 ----
  278. X  {
  279. X    unsigned int width, height;
  280. X    int x_hot, y_hot;
  281. X!   char *data, filename[255];
  282. X    int status;
  283. X  
  284. X    sprintf(filename, "%sspacer%d.bit", bitdir, scale);
  285. Xdiff -c xinvaders.2/vaders.c xinvaders/vaders.c
  286. X*** xinvaders.2/vaders.c    Tue Aug  7 15:28:22 1990
  287. X--- xinvaders/vaders.c    Thu Aug 30 10:20:55 1990
  288. X***************
  289. X*** 38,43 ****
  290. X--- 38,44 ----
  291. X    XImage *shape_image[2];
  292. X    int value;
  293. X    Boolean alive;
  294. X+   Boolean exploded;
  295. X  } VaderRec, *Vader;
  296. X  
  297. X  VaderRec vaders[NUMROWS][NUMVADERS];
  298. X***************
  299. X*** 54,59 ****
  300. X--- 55,62 ----
  301. X  
  302. X  extern Base base;
  303. X  
  304. X+ XImage *Explode_image;
  305. X+ 
  306. X  /* indicates pad around vader bitmap for better collision detection */
  307. X  #define VADERPAD     scale
  308. X  
  309. X***************
  310. X*** 77,86 ****
  311. X          0, 0, rx, ry, w, h);
  312. X  }
  313. X  
  314. X  static void DestroyVader(vader)
  315. X  Vader vader;
  316. X  {
  317. X-   int num, value;
  318. X    int oldx = vader->x;
  319. X    int oldy = vader->y;
  320. X    PaintVader(vader, backgc);
  321. X--- 80,104 ----
  322. X          0, 0, rx, ry, w, h);
  323. X  }
  324. X  
  325. X+ static void PaintExplodedVader(vader, gc)
  326. X+      Vader vader;
  327. X+      GC gc;
  328. X+ {
  329. X+   int rx, ry, w, h;
  330. X+   
  331. X+   w = Explode_image->width;
  332. X+   h = Explode_image->height;
  333. X+ 
  334. X+   rx = vader->x;
  335. X+   ry = vader->y;
  336. X+   
  337. X+   XPutImage(dpy, gamewindow, gc, Explode_image,
  338. X+         0, 0, rx, ry, w, h);
  339. X+ }
  340. X+ 
  341. X  static void DestroyVader(vader)
  342. X  Vader vader;
  343. X  {
  344. X    int oldx = vader->x;
  345. X    int oldy = vader->y;
  346. X    PaintVader(vader, backgc);
  347. X***************
  348. X*** 97,102 ****
  349. X--- 115,122 ----
  350. X      vaderwait /= 2; break;
  351. X    }
  352. X    vader->alive = FALSE;
  353. X+   vader->exploded = TRUE;
  354. X+   PaintExplodedVader(vader, vader->gc);
  355. X  }
  356. X  
  357. X  
  358. X***************
  359. X*** 158,164 ****
  360. X  {
  361. X    register Vader vader;
  362. X    register int i, j;
  363. X-   int oldx, newx;
  364. X    Boolean reversep;
  365. X  
  366. X    reversep = FALSE;
  367. X--- 178,183 ----
  368. X***************
  369. X*** 180,186 ****
  370. X      for(j = 0; j < NUMROWS; j++)
  371. X        for (i=0 ; i< NUMVADERS ; i++) {
  372. X      vader = &vaders[j][i];
  373. X!     if (vader->alive) {
  374. X        if (vader->vx > 0)
  375. X          ShotHitsBuilding(vader->x+vader->width, vader->y+vader->height);
  376. X        else
  377. X--- 199,209 ----
  378. X      for(j = 0; j < NUMROWS; j++)
  379. X        for (i=0 ; i< NUMVADERS ; i++) {
  380. X      vader = &vaders[j][i];
  381. X!     if (vader->exploded) {
  382. X!       PaintExplodedVader(vader, backgc);
  383. X!       vader->exploded = FALSE;
  384. X!     }
  385. X!     else if (vader->alive) {
  386. X        if (vader->vx > 0)
  387. X          ShotHitsBuilding(vader->x+vader->width, vader->y+vader->height);
  388. X        else
  389. X***************
  390. X*** 243,248 ****
  391. X--- 266,289 ----
  392. X        Vader_Image[i][j]->byte_order = LSBFirst;
  393. X      }
  394. X  
  395. X+   sprintf(filename, "%svexplod%d.bit", bitdir, scale); 
  396. X+   status = XmuReadBitmapDataFromFile (filename,
  397. X+                       &width, &height, &data,
  398. X+                       &x_hot, &y_hot);
  399. X+ 
  400. X+   if (status != BitmapSuccess) return status;
  401. X+ 
  402. X+   Explode_image = XCreateImage(dpy,
  403. X+                    DefaultVisual(dpy, DefaultScreen(dpy)),
  404. X+                    1,
  405. X+                    XYBitmap,
  406. X+                    0,
  407. X+                    data,
  408. X+                    width, height,
  409. X+                    8, 0);
  410. X+   Explode_image->bitmap_bit_order = LSBFirst;
  411. X+   Explode_image->byte_order = LSBFirst;
  412. X+ 
  413. X    return BitmapSuccess;
  414. X  }
  415. X  
  416. X***************
  417. X*** 263,268 ****
  418. X--- 304,310 ----
  419. X        vader->y = VADERHEIGHT*(offset+j);
  420. X        vader->vx = scale;
  421. X        vader->alive = TRUE;
  422. X+       vader->exploded = FALSE;
  423. X      }
  424. X  }
  425. X  
  426. Xdiff -c xinvaders.2/vaders.h xinvaders/vaders.h
  427. X*** xinvaders.2/vaders.h    Tue Aug  7 14:58:51 1990
  428. X--- xinvaders/vaders.h    Thu Aug 30 09:44:31 1990
  429. X***************
  430. X*** 203,208 ****
  431. X  extern void MoveShots();
  432. X  extern void MoveVshots();
  433. X  
  434. X! ext Pixel defaultback, defaultfore;
  435. X  
  436. X  #endif _vaders_h
  437. X--- 203,208 ----
  438. X  extern void MoveShots();
  439. X  extern void MoveVshots();
  440. X  
  441. X! ext Pixel defaultfore, defaultback;
  442. X  
  443. X  #endif _vaders_h
  444. XOnly in xinvaders: vexplod1.bit
  445. XOnly in xinvaders: vexplod2.bit
  446. END_OF_FILE
  447. if test 9325 -ne `wc -c <'xinvaders.3.diffs'`; then
  448.     echo shar: \"'xinvaders.3.diffs'\" unpacked with wrong size!
  449. fi
  450. # end of 'xinvaders.3.diffs'
  451. fi
  452. if test -f 'xinvaders/vexplod1.bit' -a "${1}" != "-c" ; then 
  453.   echo shar: Will not clobber existing file \"'xinvaders/vexplod1.bit'\"
  454. else
  455. echo shar: Extracting \"'xinvaders/vexplod1.bit'\" \(190 characters\)
  456. sed "s/^X//" >'xinvaders/vexplod1.bit' <<'END_OF_FILE'
  457. X#define vexplode1_width 14
  458. X#define vexplode1_height 8
  459. Xstatic char vexplode1_bits[] = {
  460. X   0x48, 0x04, 0x50, 0x02, 0x00, 0x00, 0x06, 0x18, 0x10, 0x02, 0x88, 0x04,
  461. X   0x80, 0x00, 0x00, 0x00};
  462. END_OF_FILE
  463. if test 190 -ne `wc -c <'xinvaders/vexplod1.bit'`; then
  464.     echo shar: \"'xinvaders/vexplod1.bit'\" unpacked with wrong size!
  465. fi
  466. # end of 'xinvaders/vexplod1.bit'
  467. fi
  468. if test -f 'xinvaders/vexplod2.bit' -a "${1}" != "-c" ; then 
  469.   echo shar: Will not clobber existing file \"'xinvaders/vexplod2.bit'\"
  470. else
  471. echo shar: Extracting \"'xinvaders/vexplod2.bit'\" \(491 characters\)
  472. sed "s/^X//" >'xinvaders/vexplod2.bit' <<'END_OF_FILE'
  473. X#define vexplode2_width 28
  474. X#define vexplode2_height 16
  475. Xstatic char vexplode2_bits[] = {
  476. X   0x00, 0x20, 0x00, 0x00, 0x00, 0x24, 0x01, 0x00, 0x00, 0xa8, 0x10, 0x00,
  477. X   0xc0, 0xa8, 0x0c, 0x00, 0x00, 0x03, 0x02, 0x00, 0x60, 0x00, 0x60, 0x00,
  478. X   0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
  479. X   0x80, 0x00, 0x10, 0x00, 0x60, 0x04, 0x64, 0x00, 0x00, 0x53, 0x09, 0x00,
  480. X   0xc0, 0x50, 0x11, 0x00, 0x00, 0x48, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00,
  481. X   0x00, 0x00, 0x00, 0x00};
  482. END_OF_FILE
  483. if test 491 -ne `wc -c <'xinvaders/vexplod2.bit'`; then
  484.     echo shar: \"'xinvaders/vexplod2.bit'\" unpacked with wrong size!
  485. fi
  486. # end of 'xinvaders/vexplod2.bit'
  487. fi
  488. echo shar: End of shell archive.
  489. exit 0
  490.  
  491.  
  492. dan
  493. ----------------------------------------------------
  494. O'Reilly && Associates   argv@sun.com / argv@ora.com
  495. Opinions expressed reflect those of the author only.
  496.